<template>
	<view class="login">
		<image class="bg" src="../../static/image/login_bg.png" mode=""></image>
		<image class="logo" src="../../static/image/logo.png" mode=""></image>
		<view class="title">
			社会心理服务管理平台
		</view>

	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	import {
		setBaseURL
	} from '../../utils/request.js'

	const currentUrl = window.location.origin;
	
	onLoad(() => {
		console.log('currentUrl' + currentUrl)
		setBaseURL(currentUrl)
		checkSession();
	})

	const checkSession = () => {

		try {
			const token = uni.getStorageSync('userToken')
			const docUser = uni.getStorageSync('userInfo')

			console.log('用户token' + token)
			console.log('用户信息' + docUser)

			if (token && docUser) {
				uni.switchTab({
					url: '/pages/index/index'
				})
			} else {
				uni.clearStorageSync()
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		} catch (e) {
			console.log('wentishi' + e)
		}


	}
</script>

<style lang="scss" scoped>
	.login {
		width: 100vw;
		height: 100vh;
		position: relative;

		.bg {
			width: 100%;
			height: 100%;
			display: block;
		}

		.logo {
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			position: absolute;
			top: 30%;
			left: 50%;
			transform: translateX(-50%);

		}

		.title {
			color: #fff;
			border-radius: 50%;
			position: absolute;
			top: 43%;
			left: 50%;
			transform: translateX(-50%);
			font-size: 40rpx;
		}

	}
</style>